﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.Xml;
using CodingTheTweet;

namespace TwiXaml
{
    /// <summary>
    /// Interaction logic for TweetWin.xaml
    /// </summary>
    public partial class TweetWin : Window
    {
        int charsleft;
        String username, password;
        Twitter twitter = new Twitter();
        oAuthTwitter oAuth = new oAuthTwitter();
        
       
        public TweetWin(String user, String pass)
        {
            InitializeComponent();
            this.username = user;
            this.password = pass;
            
            
          
                  

            
            
            
        }

        private void MessageBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            charsleft = MessageBox.Text.Length;
            
            counter.Text = charsleft.ToString();

            if (MessageBox.Text.Length > 140)
            {
                counter.Text = "exceeding 140 characters";

            }
            
           
           
        }

     

       private void Friends_Loaded(object sender, RoutedEventArgs e)
        {
           
          
        }

       private void Window_Closed(object sender, EventArgs e)
       {
           System.Windows.Application.Current.Shutdown();
           
       }

       private void update_Click(object sender, RoutedEventArgs e)
       {

           bool Result;

           Result = twitter.Update(MessageBox.Text);
           if (Result == true)
           {
               MessageBox.Text = "";
               counter.Text = "Tweet Sent!";
           }
           else
               counter.Text = "Unable to update Status";

       }
    }
}
